package views.accueil;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import main.NotInitializedException;
import main.SingletonJeu;
import models.projet.Projet;

public class PanelAccueilProjet extends JPanel
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ArrayList<Projet> lesProjets;
	private JPanel	LesProjets;

	public PanelAccueilProjet()
	{
		setLayout(new BorderLayout(0, 0));

		try
		{
			this.lesProjets = (ArrayList<Projet>) SingletonJeu.getLeJeu().getLeJoueur().getLesProjets();
		} catch (NotInitializedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JPanel panel = new JPanel();
		add(panel, BorderLayout.NORTH);

		LesProjets = new JPanel();
		add(LesProjets, BorderLayout.CENTER);
		LesProjets.setLayout(new GridLayout(lesProjets.size(), 2, 0, 0));
		for (Projet p : lesProjets)
		{
			JProgressBar jpb = new JProgressBar();
			try
			{
				LesProjets.add(new JLabel(p.getNom()));
				jpb.setValue(p.getAvancement(SingletonJeu.getLeJeu().getLeCalendrier().getDateActuelleDuJeu()));
			} catch (NotInitializedException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			LesProjets.add(jpb);
		}


		JPanel panel_2 = new JPanel();
		add(panel_2, BorderLayout.SOUTH);

		JPanel panel_3 = new JPanel();
		add(panel_3, BorderLayout.WEST);

		JPanel panel_4 = new JPanel();
		add(panel_4, BorderLayout.EAST);
	}

	public void refresh()
	{
		/*while
		LesProjets.getComponent(n)*/

	}

}
